#pragma     once

#include    "Misc/CommonMacros.h"

#ifdef LINUX
#include   "PlatformInterface.h"
#include    "Containers/String.h"

#include "Containers/Map.h"

class CX11Window;
class CX11Things;

class WHENGINE_API CLinuxPlatform : public IPlatformInterface
{   

public:
    CLinuxPlatform();
    ~CLinuxPlatform();  

    virtual EPlatform GetPlatform() const override
    {
        return EPlatform::Linux;
    }

    //get display work area
    //the display is  which one contains the position
    SRect GetDisplayWorkArea(const SIntPoint & InPosition ) const override;


    virtual EArchitecture GetArchitecture() const override
    {
        return EArchitecture::x64;    
    }

    TVector<const char*> GetVulkanInstanceExtensions() const override;

    int64_t CreateProcess(const CString& Command, const CString& WorkingDirectory) override;

    virtual int64_t CreateProcessWithoutBlock(const CString& Command, const CString& WorkingDirectory) override;

    virtual void KillProcess(int64_t ProcessID) override;

    TOptional<SystemEvent> PopEvents() override;


    CX11Things* GetX11Things() const
    {
        return X11Things;
    }
protected:
    CX11Things * X11Things=nullptr;
    TOptional<CString> ClipboardText;

public:
    ISytemWindowInterface * CreateSystemWindow() override;

    void DestroySystemWindow(ISytemWindowInterface * Window) override;

    virtual void StartTextInput(uint64_t WindowID, SIntPoint IMEWidgetPosition) override;

    virtual void StopTextInput() override;

    virtual bool IsTextInputStarted() const override;

    void UseSystemCursor(EMouseCursorType CursorType) override;

    virtual TVector<TTuple<CString /*Displayname*/,SPath>> GetDefaultFavoriteList() override;

    virtual bool IsKeyDown(EKey Key) override;

    //x11 clipboard ref: https://www.uninformativ.de/blog/postings/2017-04-02/0/POSTING-en.html
    virtual void SetClipboardText(const CString& Text);
    virtual bool HasClipboardText() override;
    //return empty string if clipboard is empty
    virtual CString GetClipboardText() override;


    //convert a commandline string to unicode
    virtual CString SystemStringToUnicode(const char * InArg) const override;

    virtual void CaptureMouse(uint64_t WindowID);
    virtual void ReleaseMouseCapture();
};














#endif